package b.i.d;

import android.graphics.Path;
import android.util.Log;
import b.i.b.f;

/* compiled from: PathParser */
public class c {
    public char a;
    public float[] b;

    public c(char c, float[] fArr) {
        this.a = c;
        this.b = fArr;
    }

    public static void a(Path path, float f, float f2, float f3, float f4, float f5, float f6, float f7, boolean z, boolean z2) {
        float f8 = f;
        float f9 = f3;
        float f10 = f5;
        float f11 = f6;
        boolean z3 = z2;
        double toRadians = Math.toRadians((double) f7);
        double cos = Math.cos(toRadians);
        double sin = Math.sin(toRadians);
        double d = (double) f8;
        double d2 = (double) f2;
        double d3 = (d2 * sin) + (d * cos);
        double d4 = d;
        d = (double) f10;
        d3 /= d;
        double d5 = toRadians;
        toRadians = (double) f11;
        double d6 = ((d2 * cos) + (((double) (-f8)) * sin)) / toRadians;
        double d7 = d2;
        double d8 = (double) f4;
        double d9 = ((d8 * sin) + (((double) f9) * cos)) / d;
        d8 = ((d8 * cos) + (((double) (-f9)) * sin)) / toRadians;
        double d10 = d3 - d9;
        double d11 = d6 - d8;
        double d12 = (d3 + d9) / 2.0d;
        double d13 = (d6 + d8) / 2.0d;
        double d14 = sin;
        sin = (d11 * d11) + (d10 * d10);
        String str = "PathParser";
        if (sin == 0.0d) {
            Log.w(str, " Points are coincident");
            return;
        }
        double d15 = (1.0d / sin) - 0.25d;
        if (d15 < 0.0d) {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("Points are too far apart ");
            stringBuilder.append(sin);
            Log.w(str, stringBuilder.toString());
            f8 = (float) (Math.sqrt(sin) / 1.99999d);
            a(path, f, f2, f3, f4, f10 * f8, f6 * f8, f7, z, z2);
            return;
        }
        sin = Math.sqrt(d15);
        d10 *= sin;
        sin *= d11;
        if (z == z3) {
            d12 -= sin;
            d13 += d10;
        } else {
            d12 += sin;
            d13 -= d10;
        }
        d10 = Math.atan2(d6 - d13, d3 - d12);
        double atan2 = Math.atan2(d8 - d13, d9 - d12) - d10;
        int i = 0;
        int i2 = (atan2 > 0.0d ? 1 : (atan2 == 0.0d ? 0 : -1));
        if (z3 != (i2 >= 0)) {
            atan2 = i2 > 0 ? atan2 - 6.283185307179586d : atan2 + 6.283185307179586d;
        }
        d12 *= d;
        d13 *= toRadians;
        double d16 = (d12 * cos) - (d13 * d14);
        d13 = (d13 * cos) + (d12 * d14);
        i2 = (int) Math.ceil(Math.abs((atan2 * 4.0d) / 3.141592653589793d));
        sin = Math.cos(d5);
        d3 = Math.sin(d5);
        d5 = Math.cos(d10);
        d6 = Math.sin(d10);
        cos = -d;
        d9 = cos * sin;
        d12 = toRadians * d3;
        d11 = (d9 * d6) - (d12 * d5);
        cos *= d3;
        toRadians *= sin;
        d5 = (d5 * toRadians) + (d6 * cos);
        atan2 /= (double) i2;
        d10 = d10;
        while (i < i2) {
            d6 = d10 + atan2;
            double sin2 = Math.sin(d6);
            d14 = Math.cos(d6);
            double d17 = atan2;
            atan2 = (((d * sin) * d14) + d16) - (d12 * sin2);
            double d18 = d16;
            d16 = (toRadians * sin2) + (((d * d3) * d14) + d13);
            d15 = (d9 * sin2) - (d12 * d14);
            sin2 = (d14 * toRadians) + (sin2 * cos);
            d10 = d6 - d10;
            d14 = Math.tan(d10 / 2.0d);
            double sqrt = ((Math.sqrt(((d14 * 3.0d) * d14) + 4.0d) - 1.0d) * Math.sin(d10)) / 3.0d;
            d10 = (d11 * sqrt) + d4;
            int i3 = i2;
            double d19 = toRadians;
            double d20 = (d5 * sqrt) + d7;
            double d21 = cos;
            cos = atan2 - (sqrt * d15);
            d5 = sin;
            sin = d16 - (sqrt * sin2);
            d7 = d;
            path.rLineTo(0.0f, 0.0f);
            path.cubicTo((float) d10, (float) d20, (float) cos, (float) sin, (float) atan2, (float) d16);
            i++;
            toRadians = d19;
            cos = d21;
            i2 = i3;
            sin = d5;
            d10 = d6;
            d = d7;
            d5 = sin2;
            d11 = d15;
            d4 = atan2;
            d7 = d16;
            atan2 = d17;
            d16 = d18;
        }
    }

    public static void b(c[] cVarArr, Path path) {
        c[] cVarArr2 = cVarArr;
        Path path2 = path;
        float[] fArr = new float[6];
        char c = 'm';
        int i = 0;
        char c2 = 'm';
        int i2 = 0;
        while (i2 < cVarArr2.length) {
            int i3;
            int i4;
            float f;
            char c3 = cVarArr2[i2].a;
            float[] fArr2 = cVarArr2[i2].b;
            float f2 = fArr[i];
            float f3 = fArr[1];
            float f4 = fArr[2];
            float f5 = fArr[3];
            float f6 = fArr[4];
            float f7 = fArr[5];
            switch (c3) {
                case 'A':
                case 'a':
                    i3 = 7;
                    break;
                case 'C':
                case 'c':
                    i3 = 6;
                    break;
                case 'H':
                case 'V':
                case 'h':
                case 'v':
                    i3 = 1;
                    break;
                case 'Q':
                case 'S':
                case 'q':
                case 's':
                    i3 = 4;
                    break;
                case 'Z':
                case 'z':
                    path.close();
                    path2.moveTo(f6, f7);
                    f2 = f6;
                    f4 = f2;
                    f3 = f7;
                    f5 = f3;
                    break;
            }
            i3 = 2;
            float f8 = f6;
            float f9 = f7;
            f7 = f2;
            f6 = f3;
            int i5 = 0;
            while (i5 < fArr2.length) {
                int i6;
                float[] fArr3;
                char c4;
                int i7;
                if (c3 != 'A') {
                    float f10;
                    float f11;
                    int i8;
                    if (c3 != 'C') {
                        int i9;
                        if (c3 == 'H') {
                            i6 = i5;
                            fArr3 = fArr2;
                            c4 = c3;
                            i4 = i2;
                            i5 = i6 + 0;
                            path2.lineTo(fArr3[i5], f6);
                            f7 = fArr3[i5];
                        } else if (c3 == 'Q') {
                            i6 = i5;
                            fArr3 = fArr2;
                            c4 = c3;
                            i4 = i2;
                            i5 = i6 + 0;
                            i9 = i6 + 1;
                            int i10 = i6 + 2;
                            int i11 = i6 + 3;
                            path2.quadTo(fArr3[i5], fArr3[i9], fArr3[i10], fArr3[i11]);
                            f10 = fArr3[i5];
                            f11 = fArr3[i9];
                            f7 = fArr3[i10];
                            f6 = fArr3[i11];
                        } else if (c3 == 'V') {
                            i6 = i5;
                            fArr3 = fArr2;
                            c4 = c3;
                            i4 = i2;
                            i5 = i6 + 0;
                            path2.lineTo(f7, fArr3[i5]);
                            f6 = fArr3[i5];
                        } else if (c3 != 'a') {
                            int i12;
                            if (c3 != 'c') {
                                int i13;
                                int i14;
                                if (c3 == 'h') {
                                    i6 = i5;
                                    f = f6;
                                    f10 = f7;
                                    i5 = i6 + 0;
                                    path2.rLineTo(fArr2[i5], 0.0f);
                                    f7 = f10 + fArr2[i5];
                                } else if (c3 != 'q') {
                                    if (c3 == 'v') {
                                        i6 = i5;
                                        f = f6;
                                        f10 = f7;
                                        i5 = i6 + 0;
                                        path2.rLineTo(0.0f, fArr2[i5]);
                                        f10 = fArr2[i5];
                                    } else if (c3 != 'L') {
                                        if (c3 == 'M') {
                                            i6 = i5;
                                            i5 = i6 + 0;
                                            f10 = fArr2[i5];
                                            i9 = i6 + 1;
                                            f2 = fArr2[i9];
                                            if (i6 > 0) {
                                                path2.lineTo(fArr2[i5], fArr2[i9]);
                                                f7 = f10;
                                                f6 = f2;
                                            } else {
                                                path2.moveTo(fArr2[i5], fArr2[i9]);
                                                f8 = f10;
                                                f9 = f2;
                                            }
                                        } else if (c3 == 'S') {
                                            i6 = i5;
                                            f = f6;
                                            f10 = f7;
                                            if (c2 == 'c' || c2 == 's' || c2 == 'C' || c2 == 'S') {
                                                f3 = (f * 2.0f) - f5;
                                                f2 = (f10 * 2.0f) - f4;
                                            } else {
                                                f2 = f10;
                                                f3 = f;
                                            }
                                            i8 = i6 + 0;
                                            i7 = i6 + 1;
                                            int i15 = i6 + 2;
                                            i = i6 + 3;
                                            path.cubicTo(f2, f3, fArr2[i8], fArr2[i7], fArr2[i15], fArr2[i]);
                                            f10 = fArr2[i8];
                                            f11 = fArr2[i7];
                                            f2 = fArr2[i15];
                                            f3 = fArr2[i];
                                            f4 = f10;
                                            f5 = f11;
                                            f7 = f2;
                                            f6 = f3;
                                        } else if (c3 == 'T') {
                                            i6 = i5;
                                            f = f6;
                                            f10 = f7;
                                            if (c2 == 'q' || c2 == 't' || c2 == 'Q' || c2 == 'T') {
                                                f7 = (f10 * 2.0f) - f4;
                                                f6 = (f * 2.0f) - f5;
                                            } else {
                                                f7 = f10;
                                                f6 = f;
                                            }
                                            i5 = i6 + 0;
                                            i9 = i6 + 1;
                                            path2.quadTo(f7, f6, fArr2[i5], fArr2[i9]);
                                            f5 = f6;
                                            f4 = f7;
                                            fArr3 = fArr2;
                                            c4 = c3;
                                            i4 = i2;
                                            f7 = fArr2[i5];
                                            f6 = fArr2[i9];
                                        } else if (c3 == 'l') {
                                            i6 = i5;
                                            f = f6;
                                            f10 = f7;
                                            i5 = i6 + 0;
                                            i13 = i6 + 1;
                                            path2.rLineTo(fArr2[i5], fArr2[i13]);
                                            f7 = f10 + fArr2[i5];
                                            f10 = fArr2[i13];
                                        } else if (c3 == c) {
                                            i6 = i5;
                                            i5 = i6 + 0;
                                            f7 += fArr2[i5];
                                            i8 = i6 + 1;
                                            f6 += fArr2[i8];
                                            if (i6 > 0) {
                                                path2.rLineTo(fArr2[i5], fArr2[i8]);
                                            } else {
                                                path2.rMoveTo(fArr2[i5], fArr2[i8]);
                                                f9 = f6;
                                                f8 = f7;
                                            }
                                        } else if (c3 != 's') {
                                            if (c3 == 't') {
                                                float f12;
                                                if (c2 == 'q' || c2 == 't' || c2 == 'Q' || c2 == 'T') {
                                                    f12 = f7 - f4;
                                                    f11 = f6 - f5;
                                                } else {
                                                    f11 = 0.0f;
                                                    f12 = 0.0f;
                                                }
                                                i13 = i5 + 0;
                                                i14 = i5 + 1;
                                                path2.rQuadTo(f12, f11, fArr2[i13], fArr2[i14]);
                                                f12 += f7;
                                                f11 += f6;
                                                f7 += fArr2[i13];
                                                f6 += fArr2[i14];
                                                f5 = f11;
                                                f4 = f12;
                                            }
                                            i6 = i5;
                                        } else {
                                            float f13;
                                            if (c2 == 'c' || c2 == 's' || c2 == 'C' || c2 == 'S') {
                                                f13 = f6 - f5;
                                                f2 = f7 - f4;
                                            } else {
                                                f2 = 0.0f;
                                                f13 = 0.0f;
                                            }
                                            i7 = i5 + 0;
                                            i = i5 + 1;
                                            i12 = i5 + 2;
                                            int i16 = i5 + 3;
                                            i6 = i5;
                                            f = f6;
                                            f10 = f7;
                                            path.rCubicTo(f2, f13, fArr2[i7], fArr2[i], fArr2[i12], fArr2[i16]);
                                            f11 = fArr2[i7] + f10;
                                            f2 = fArr2[i] + f;
                                            f7 = f10 + fArr2[i12];
                                            f10 = fArr2[i16];
                                        }
                                        f7 = f8;
                                        f6 = f9;
                                    } else {
                                        i6 = i5;
                                        i5 = i6 + 0;
                                        i9 = i6 + 1;
                                        path2.lineTo(fArr2[i5], fArr2[i9]);
                                        f7 = fArr2[i5];
                                        f6 = fArr2[i9];
                                    }
                                    f6 = f + f10;
                                } else {
                                    i6 = i5;
                                    f = f6;
                                    f10 = f7;
                                    i5 = i6 + 0;
                                    i13 = i6 + 1;
                                    i14 = i6 + 2;
                                    int i17 = i6 + 3;
                                    path2.rQuadTo(fArr2[i5], fArr2[i13], fArr2[i14], fArr2[i17]);
                                    f11 = fArr2[i5] + f10;
                                    f2 = fArr2[i13] + f;
                                    f10 += fArr2[i14];
                                    f3 = fArr2[i17];
                                    f7 = f10;
                                    f10 = f3;
                                }
                                fArr3 = fArr2;
                                c4 = c3;
                                i4 = i2;
                            } else {
                                i6 = i5;
                                f = f6;
                                f10 = f7;
                                i7 = i6 + 2;
                                i = i6 + 3;
                                int i18 = i6 + 4;
                                i12 = i6 + 5;
                                path.rCubicTo(fArr2[i6 + 0], fArr2[i6 + 1], fArr2[i7], fArr2[i], fArr2[i18], fArr2[i12]);
                                f11 = fArr2[i7] + f10;
                                f2 = fArr2[i] + f;
                                f7 = f10 + fArr2[i18];
                                f10 = fArr2[i12];
                            }
                            f3 = f + f10;
                            f4 = f11;
                            f5 = f2;
                            f2 = f7;
                            f7 = f2;
                            f6 = f3;
                            fArr3 = fArr2;
                            c4 = c3;
                            i4 = i2;
                        } else {
                            i6 = i5;
                            f = f6;
                            f10 = f7;
                            i7 = i6 + 5;
                            f4 = fArr2[i7] + f10;
                            i = i6 + 6;
                            f5 = fArr2[i] + f;
                            f6 = fArr2[i6 + 0];
                            f7 = fArr2[i6 + 1];
                            float f14 = fArr2[i6 + 2];
                            boolean z = fArr2[i6 + 3] != 0.0f;
                            boolean z2 = fArr2[i6 + 4] != 0.0f;
                            fArr3 = fArr2;
                            float f15 = f14;
                            c4 = c3;
                            i4 = i2;
                            a(path, f10, f, f4, f5, f6, f7, f15, z, z2);
                            f7 = f10 + fArr3[i7];
                            f6 = f + fArr3[i];
                        }
                        i5 = i6 + i3;
                        c2 = c4;
                        c3 = c2;
                        fArr2 = fArr3;
                        i2 = i4;
                        c = 'm';
                        cVarArr2 = cVarArr;
                    } else {
                        i6 = i5;
                        fArr3 = fArr2;
                        c4 = c3;
                        i4 = i2;
                        i8 = i6 + 2;
                        int i19 = i6 + 3;
                        int i20 = i6 + 4;
                        i2 = i6 + 5;
                        path.cubicTo(fArr3[i6 + 0], fArr3[i6 + 1], fArr3[i8], fArr3[i19], fArr3[i20], fArr3[i2]);
                        f11 = fArr3[i20];
                        f2 = fArr3[i2];
                        f10 = fArr3[i8];
                        f7 = f11;
                        f6 = f2;
                        f11 = fArr3[i19];
                    }
                    f4 = f10;
                    f5 = f11;
                    i5 = i6 + i3;
                    c2 = c4;
                    c3 = c2;
                    fArr2 = fArr3;
                    i2 = i4;
                    c = 'm';
                    cVarArr2 = cVarArr;
                } else {
                    i6 = i5;
                    fArr3 = fArr2;
                    c4 = c3;
                    i4 = i2;
                    i7 = i6 + 5;
                    i = i6 + 6;
                    a(path, f7, f6, fArr3[i7], fArr3[i], fArr3[i6 + 0], fArr3[i6 + 1], fArr3[i6 + 2], fArr3[i6 + 3] != 0.0f, fArr3[i6 + 4] != 0.0f);
                    f7 = fArr3[i7];
                    f6 = fArr3[i];
                }
                f5 = f6;
                f4 = f7;
                i5 = i6 + i3;
                c2 = c4;
                c3 = c2;
                fArr2 = fArr3;
                i2 = i4;
                c = 'm';
                cVarArr2 = cVarArr;
            }
            f = f6;
            i4 = i2;
            fArr[0] = f7;
            fArr[1] = f;
            fArr[2] = f4;
            fArr[3] = f5;
            fArr[4] = f8;
            fArr[5] = f9;
            i2 = i4 + 1;
            c2 = cVarArr[i4].a;
            c = 'm';
            i = 0;
            cVarArr2 = cVarArr;
        }
    }

    public c(c cVar) {
        this.a = cVar.a;
        float[] fArr = cVar.b;
        this.b = f.a0(fArr, 0, fArr.length);
    }
}
